package _11Collection接口;

import java.util.ArrayList;
import java.util.List;
//List接口的增删查改
public class DemoList {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("java");
        list.add("python");
        list.add("c++");


        //在指定位置插入元素
        list.add(1,"go");
        System.out.println(list);

        //删除指定位置的元素
        String remove = list.remove(1);
        System.out.println(remove);

        //替换指定索引处的元素,返回被替换的元素
        String mysql = list.set(1, "mysql");
        System.out.println(mysql);

        System.out.println("====================================================");

        //根据指引查询元素
        for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.println(s);
        }
    }
}
